import 'package:FineArt/constants.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

/// 列表项
class GridItemPhoto extends StatelessWidget {
  // 文字
  final String url;

  //点击事件
  final GestureTapCallback onTap;
  final double width;
  final double height;
  final BoxFit boxFit;
  // 构造函数
  const GridItemPhoto({Key key, this.url, this.onTap, this.width, this.height=0,this.boxFit=BoxFit.cover})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
        onTap: onTap,
        child: Padding(
          padding: EdgeInsets.all(1),
          child: Column(children: <Widget>[
            Expanded(
              child: Container(
                  alignment: Alignment.center,
                  color: Colors.white,
                  child: Image(
                      fit: boxFit,
                      width: width,
                      height: height,
                      image: CachedNetworkImageProvider(
                        url,
                      ))),
            ),
          ]),
        ));
  }
}
